<template>
  <view class="card_make">
    <view class="information" :style="{ paddingTop: statusBarHeight }">
      <view class="back" @click="$ui.back()"></view>
      <view class="box-top flex-row-start">
        <view class="box-top-left flex-col-between-center">
          <view class="flex-col-between-center">
            <view class="box-tit">消耗积分</view>
            <view class="box-count">{{list.get_energy}}个</view>
          </view>
          <view class="flex-col-between-center">
            <view class="box-tit">赠送</view>
            <view class="box-count">{{list.give_bonus}}个PICB</view>
          </view>
          <view class="flex-col-between-center">
            <view class="box-tit">合约</view>
            <view class="box-count">{{list.rate_days}}</view>
          </view>
        </view>
        <view class="box-top-right flex-col-between-center">
          <view class="flex-row-center">
            <text class="box-tit">收益</text>
            <text class="box-count">{{list.rate}}</text>
          </view>
          <view class="flex-row-center">
            <text class="box-tit">价值</text>
            <text class="box-count">{{list.price}}</text>
          </view>
          <view class="flex-row-center">
            <text class="box-tit">时间</text>
            <text class="box-count">{{list.time_slot}}</text>
          </view>
        </view>
      </view>
      <view class="quality">{{list.name}}</view>
    </view>
    <view class="appointment flex-row-start">
      <view class="right">
        <view class="right-img">
          <image :src="list.logo" mode="widthFix"></image>
        </view>

      </view>
      <view class="left">
        <view class="top flex-row-between">
          <u-count-down :time="list.countdown" format="HH:mm:ss" autoStart millisecond @change="onChange">
            <view class="time">
              <view class="time__custom">
                <text class="time__custom__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}</text>
              </view>
              <text class="time__doc">:</text>
              <view class="time__custom">
                <text class="time__custom__item">{{ timeData.minutes>10?timeData.minutes:'0'+timeData.minutes }}</text>
              </view>
              <text class="time__doc">:</text>
              <view class="time__custom">
                <text class="time__custom__item">{{ timeData.seconds>10?timeData.seconds:'0'+timeData.seconds }}</text>
              </view>
            </view>
          </u-count-down>
        </view>
      </view>
    </view>
    <view class="swiper-view-box">
      <view class="swiper_title">
        {{list.introduce || '详情介绍请等待公布具体内容'}}
      </view>
      <div v-if="list.status == 3 && list.s_time >= list.SubscribeTime" class="button_bo">
        待开放
      </div>
      <div v-else-if="list.p_status == 1 && list.s_time >= list.SubscribeTime" class="button_bo"
        @click.stop="get_home_point(list)">
        {{ list.p_status | fixStatus }}
      </div>
      <div v-else-if="list.p_status == 4 && list.s_time >= list.SubscribeTime" class="button_bo">
        {{ list.p_status | fixStatus }}
      </div>
      <div v-else class="button_bo" :class="list.p_status == 5 ? 'pet-status-zzz' : ''">
        <span
          v-if="list.p_status == 2 || list.p_status == 5 || list.p_status == 6 || (list.p_status == 3 && list.s_time >= list.SubscribeTime)">{{ list.p_status | fixStatus }}</span>
      </div>
    </view>
  </view>
</template>

<script>
  import {
    homeAppoint
  } from '../../api/mAdoptingRecord.js'
  export default {
    data() {
      return {
        statusBarHeight: 20,
        list3: [
          '../../static/cardService/ring.png',
          '../../static/cardService/ring.png',
          '../../static/cardService/ring.png',
        ],
        list: [],
        timeData: {},
      }
    },
    filters: {
      fixStatus(status) {
        return status === 1 ?
          '预约' :
          status === 2 ?
          '已经预约' :
          status === 3 ?
          '准备匹配' :
          status === 4 ?
          '正在抢购' :
          status === 5 ?
          '正在收益' :
          status === 6 ?
          '抢购中' :
          ''
      },
      fixTime(val) {
        return val >= 10 ? val : '0' + val
      }
    },
    onLoad(opt) {
      this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 10 + 'px'
      this.list = JSON.parse(opt.list)
      console.log(this.list);
    },
    methods: {
      // 会员预约
      get_home_point(item) {
        console.log(123123)
        this.$ui.show('预约提醒', '预约水果，自动分配', true).then(res => {
          if (res.confirm) {
            this.sureAppoint(item)
          }
        })
      },
      // 实际预约
      sureAppoint(item) {
        const vm = this
        homeAppoint({
          id: item.id
        }).then((res) => {
          if (res.code === 1) {
            vm.$ui.toast(res.msg)
            setTimeout(() => {
              uni.navigateBack()
            }, 1000)
          } else {
            vm.$ui.toast(res.msg)
          }
        })
      },
      onChange(e) {
        this.timeData = e
      },
      handleChange(e) {
        // console.log(e.detail.current);
      }
    }
  }
</script>

<style lang="less" scoped>
  .card_make {
    .information {
      height: 100vh;
      background-image: url(@/static/cardService/make.png);
      background-size: 100%;
      background-repeat: no-repeat;
      box-sizing: border-box;
      background-color: red;

      // padding-top: 65rpx;
      .back {
        width: 15rpx;
        height: 29rpx;
        background-image: url(@/static/cardService/back.png);
        background-repeat: no-repeat;
        background-size: cover;
        margin-left: 21rpx;
        margin-bottom: 50rpx;
      }

      .box-top {
        margin-top: 143rpx;
        &>view {
          flex: 1;
        }

        .box-top-left {
          .box-tit {
            height: 22rpx;
            line-height: 22rpx;
            font-size: 23rpx;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
          }

          .box-count {
            height: 25rpx;
            line-height: 25rpx;
            font-size: 26rpx;
            font-family: PingFang SC;
            font-weight: 500;
            color: #F4D081;
            margin-top: 17rpx;
          }
        }

        .box-top-right {
          width: 371rpx;
          height: 290rpx;
          background: #151515;
          opacity: 0.7;
          border-radius: 35rpx;
          margin-right: 30rpx;
          box-sizing: border-box;
          padding: 57rpx 0 58rpx 33rpx;

          &>view {
            width: 100%;
          }

          .box-tit {
            height: 24rpx;
            line-height: 24rpx;
            font-size: 25rpx;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
          }

          .box-count {
            height: 20rpx;
            line-height: 20rpx;
            font-size: 26rpx;
            font-family: PingFang SC;
            font-weight: 500;
            color: #F4D081;
            margin-left: 81rpx;
          }
        }
      }

      .quality {
        margin-top: 48rpx;
        text-align: right;
        font-size: 50rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #EAC16B;
        box-sizing: border-box;
        padding-right: 126rpx;
      }
    }

    .appointment {
      position: absolute;
      top: 600rpx;
      left: 410rpx;
      height: 298rpx;

      &>view {
        flex: 1;
        height: 100%;
      }

      .left {
        margin-top: 150rpx;
        .time {
          display: flex;
          align-items: center;

          &__custom {
            margin-top: 4px;
            width: 75rpx;
            height: 53rpx;
            background-color: #323232;
            border-radius: 4px;
            display: flex;
            justify-content: center;
            align-items: center;

            &__item {
              font-size: 46rpx;
              font-family: PingFang SC;
              font-weight: 400;
              color: #FFFFFF;
              text-align: center;
            }
          }

          &__doc {
            color: #323232;
            padding: 0px 4px;
          }

          &__item {
            color: #606266;
            font-size: 15px;
            margin-right: 4px;
          }
        }

        .top {
          width: 227rpx;
          margin: 0 auto;
          padding-top: 58rpx;

          .box {
            width: 75rpx;
            height: 53rpx;
            color: #FFFFFF;
            background: #030303;
            border-radius: 2rpx;
            text-align: center;
            line-height: 53rpx;
          }
        }

        .bottom {
          width: 223rpx;
          height: 77rpx;
          background: linear-gradient(45deg, #B5A96F 0%, #AE9759 100%);
          border-radius: 38rpx;
          margin: 0 auto;
          margin-top: 8rpx;
          text-align: center;
          line-height: 77rpx;
          font-size: 41rpx;
          font-family: PingFang SC;
          font-weight: 500;
          color: #FFFFFF;
        }
      }

      .right {
        position: relative;
        width: 50%;
        height: 313rpx;

        .right-img {
          width: 409rpx;
          height: 313rpx;
          position: absolute;
          right: 0;
          top: -50rpx;
          image {
            width: 100%;
          }
        }
      }
    }

    .swiper-view-box {
      position: relative;
      width: 100vw;
      min-height: calc(100% - 1000rpx);
      background: #FFFFFF;
      box-shadow: 0px 0px 31rpx 1rpx rgba(0, 0, 0, 0.11);
      box-sizing: border-box;
      padding-top: 50rpx;
      position: fixed;
      left: 0;
      bottom: 0;

      .swiper_title {
        margin: 0 auto;
        width: 648rpx;
        height: 56rpx;
        font-size: 26rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #333333;
      }

      .button_bo {
        position: absolute;
        bottom: 55rpx;
        left: 50%;
        transform: translateX(-50%);
        width: 646rpx;
        height: 80rpx;
        background: linear-gradient(45deg, #B5A96F 0%, #AE9759 100%);
        border-radius: 38rpx;
        font-size: 41rpx;
        line-height: 80rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        text-align: center;
      }
    }
  }
</style>
